package com.jiazhong.boot.alipay.controller;

import com.jiazhong.boot.alipay.bean.Alipay;
import com.jiazhong.boot.alipay.service.AlipayService;
import com.jiazhong.boot.commons.util.JsonResult;
import com.jiazhong.boot.commons.util.ResultTool;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/alipay")
public class AlipayController {
    @Resource
    private AlipayService alipayService;

    @PostMapping("/pay")
    public String pay(Alipay alipay) {
        return alipayService.pay(alipay);
    }

    @GetMapping("/success")
    public JsonResult success() {
        return ResultTool.success("支付成功");
    }

    @GetMapping("/refund")
    public JsonResult refund(Alipay alipay) {
        return ResultTool.success(alipayService.refund(alipay));
    }

    @GetMapping("/query")
    public JsonResult query(Alipay alipay) {
        return ResultTool.success(alipayService.query(alipay));
    }
}
